## Add-VerbException.ps1
## Add a non-standard verb to the database, with an exception given to
## a specific project
param(
    ## Connection parameters
    $server, $database, 
    ## Verb parameters. Specify a description to add the verb as 
    ## well.
    $type, $name, $definition, $comments, $obsoletes, $pair, 
    ## The name of the project to grant the exclusion
    $projectName)

## If they supply a definition, we need to add the verb, too
if($definition)
{
    $sql = @"
         INSERT INTO [Verb]
               ([Type], [Name], [Definition], [Comments], [Obsoletes], [Pair])
         VALUES
               ('$type', '$name', '$definition', '$comments', '$obsoletes', '$pair')
"@

    Invoke-SqlCommand $server $database $sql
}

if($projectName)
{
    ## Now update the VerbException table
    $sql = @"
    DECLARE @projectId INT
    SET @projectId = (SELECT ProjectId FROM Project
                      WHERE Name = '$projectName')

    INSERT INTO [VerbException]
           ([Name], [ProjectId])
    VALUES
           ('$name', @projectId)
"@

    Invoke-SqlCommand $server $database $sql
}